<?php

namespace Controller\User;

class MoreSingle extends Base {

    public function actionIndex() {
        $categoryId = $this->getInt('c');
        $categoryInfo = array();
        if ($categoryId) {
            $categoryInfo = \Business\Category::instance()->getCategoryById($categoryId);
            if (!$categoryInfo) {
                $this->throwException('分类信息不存在');
            }
        }

        $pager = new \Lib\Core\Pager();
        $pager->currentPage = $this->getInt('page', 1);
        $articles = \Business\Article::instance()->findArticleByUserId($pager, $this->userId, $categoryId);
        $count = \Business\Article::instance()->getUserArticleCountByUserId($this->userId);
        $categoryInfoAndNumbers = \Business\Article::instance()->getHasArticleCategory($this->userId);
        $this->assign('categoryInfoAndNumbers', $categoryInfoAndNumbers);
        $this->assign('pager', $pager);
        $this->assign('articles', $articles);
        $this->assign('count', $count);
        $this->assign('categoryInfo', $categoryInfo);
        $this->display();
    }
}